package com.cee.admin.modules.cc.controller;


import com.cee.common.web.result.Result;
import com.cee.domain.modules.cc.entity.CcEmissionSource;
import com.cee.domain.modules.cc.form.add.CcGhgFormulaColumnAddForm;
import com.cee.domain.modules.cc.vo.CcGhgFormulaColumnVo;
import com.cee.ds.modules.cc.service.ICcGhgFormulaColumnService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.cee.admin.common.BaseController;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.Collection;
import java.util.List;

/**
 * <p>
 * GHG计算列配置 前端控制器
 * </p>
 *
 * @author autoGenerator
 * @since 2023-12-22
 */
@RestController
@RequestMapping("/api/v1/carbonComponent/ghgFormula/column")
@Tag(name = "碳组件—ghg计算公式-列")
public class CcGhgFormulaColumnController extends BaseController {

    @Autowired
    private ICcGhgFormulaColumnService ghgFormulaColumnService;

    @GetMapping("/list")
    @Operation(summary = "根据下级所有节点")
    public Result<List<CcGhgFormulaColumnVo>> list(Integer parentId) {
        return success(ghgFormulaColumnService.listVo(parentId));
    }

    @PostMapping("/add")
    @Operation(summary = "添加")
    public Result<Boolean> add(@RequestBody @Valid CcGhgFormulaColumnAddForm addForm) {
        return success(ghgFormulaColumnService.add(addForm));
    }

    @PostMapping("/delete-batch")
    @Operation(summary = "批量删除")
    public Result<Boolean> delete(@RequestBody @Valid @NotEmpty List<Integer> idList) {
        return success(ghgFormulaColumnService.removeByIds(idList));
    }

    @PostMapping("/industryEmissionList")
    @Operation(summary = "获取行业相关排放源集合")
    public Result<List<CcEmissionSource>> list(@RequestParam @Parameter(description = "行业ID") Integer industryId, @Parameter(description = "排放源流ID集合") @RequestBody Collection<Integer> originIds) {
        return success(ghgFormulaColumnService.listEmissionSource(industryId, originIds));
    }
}

